home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2004 #2 / K-CD-2-2004.ISO / OpenOffice Sv / f_0397 / python-core-2.2.2 / lib / lib-old / lockfile.py < prev    next >
Encoding:
Python Source  |  2003-07-18  |  281 b   |  16 lines

  1. import struct, fcntl
  2.  
  3. def writelock(f):
  4.     _lock(f, fcntl.F_WRLCK)
  5.  
  6. def readlock(f):
  7.     _lock(f, fcntl.F_RDLCK)
  8.  
  9. def unlock(f):
  10.     _lock(f, fcntl.F_UNLCK)
  11.  
  12. def _lock(f, op):
  13.     dummy = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW,
  14.                 struct.pack('2h8l', op,
  15.                     0, 0, 0, 0, 0, 0, 0, 0, 0))
  16.